package cn.opopopo.design_pattern_learn.创建型.prototype;

import java.io.Serializable;

// Student.java - 具体原型类
public class Student implements Cloneable , Serializable {
    private String name;
    private String course;

    public Student(String name, String course) {
        this.name = name;
        this.course = course;
    }

    // Getter 和 Setter
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCourse() {
        return course;
    }

    public void setCourse(String course) {
        this.course = course;
    }

    // 重写 clone 方法
    @Override
    protected Student clone() {
        try {
            return (Student) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new AssertionError("Clone not supported for Student", e);
        }
    }

    @Override
    public String toString() {
        return "Student{name='" + name + "', course='" + course + "'}";
    }
}